package com.wst.controller.rfid;

import com.wst.entity.rfid.WmOmNoticeHEntity;
import com.wst.service.rfid.WmOmNoticeHService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.List;

@CrossOrigin
@Controller
@RequestMapping("/WmOmNoticeHController")
public class WmOmNoticeHController {
    /**
     * Logger for this class
     */

    @Autowired
    private WmOmNoticeHService wmOmNoticeHService;

    @ResponseBody
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public List<WmOmNoticeHEntity> list() {
        List<WmOmNoticeHEntity> list = wmOmNoticeHService.findAll();
        return list;
    }

    @ResponseBody
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public int insertNewValue(String token, String name) {
        WmOmNoticeHEntity wmOmNoticeHEntity = new WmOmNoticeHEntity();
        wmOmNoticeHEntity.setCreateName("毅哥");
        wmOmNoticeHEntity.setCreateBy("admin");
        try {
            wmOmNoticeHEntity.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2019-5-08 14:30:20"));
            wmOmNoticeHEntity.setDelvData(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2019-5-08 14:30:20"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        wmOmNoticeHEntity.setSysOrgCode("A06");
        wmOmNoticeHEntity.setSysCompanyCode("A05");
        wmOmNoticeHEntity.setCusCode("xkn");
        wmOmNoticeHEntity.setDelvAddr("上海");
        wmOmNoticeHEntity.setOmSta("计划中");
        wmOmNoticeHEntity.setOmNoticeId("CK20190106-0002");
        wmOmNoticeHEntity.setOrderTypeCode("11");
        wmOmNoticeHEntity.setPrintStatus("已打印");
        System.out.println(name);
        return wmOmNoticeHService.save(wmOmNoticeHEntity);
    }
}
